require 'digest/sha1'
class Paper < ActiveRecord::Base
   validates_presence_of   :title,:author,:publisher,:ISBN,:page_info,:abstract,:keyword1,:keyword2
   validates_uniqueness_of   :title,:ISBN
  acts_as_ferret :fields => [:title,:author,:publisher,:ISBN,:abstract]
 def self.full_text_search(q, options = {})
   return nil if q.nil? or q==""
   default_options = {:limit => 10, :page => 1}
   options = default_options.merge options
   
   # get the offset based on what page we're on
   options[:offset] = options[:limit] * (options.delete(:page).to_i-1)  
   
   # now do the query with our options
   results = Paper.find_by_contents(q, options)
   return [results.total_hits, results]
end
end